Title Banner


Technotes


Resource Manager Tips



Technote TB 23June 1986



Revised by: March 1988
Written by: Jim Friedlander June 1986

This note discusses some problems with the Resource Manager and how to work around them.



OpenResFile Bug

This section of the note formerly described a bug in OpenResFile on 64K ROM machines. Information specific to 64K ROM machines has been deleted from Macintosh Technical Notes for reasons of clarity.

GetMenu and ResErrProc

If your application makes use of ResErrProc (a pointer to a procedure stored in low-memory global $AF2) to detect resource errors, you will get unexpected calls to your ResErrProc procedure when calling GetMenu on 128K ROMs. The Menu Manager call GetMenu makes a call to GetResInfo, requesting resource information about MDEF 0. Unfortunately, ROMMapInsert is set to FALSE, so this call fails, setting ResErr to -192 (resNotFound). This in turn will cause a call to your ResErrProc, procedure even though the GetMenu call has worked correctly. This is only a problem if you are using ResErrProc.

The workaround is to:

1) save the address of your ResErrProc procedure

2) clear ResErrProc

3) do a GetResource call on the MENU resource you want to get

4) check to see if you get a nil handle back, if you do, you can handle the error in

  whatever way is appropriate for your application

5) call GetMenu, and

6) when you are done calling GetMenu, restore ResErrProc

SetResAttrs on read-only resource maps

SetResAttrs does not return an error if you are setting the resource attributes of a resource in a resource file that has a read-only resource map. The workaround is to check to see if the map is read-only and proceed from there:

	CONST
	    MapROBit = 8; {Toolbox bit ordering for bit 7 of low-order byte}

	BEGIN
	    ...
	    attrs:= GetResFileAttrs(refNum);
	    IF BitTst(@attrs,MapROBit) THEN ... {write-protected map}


Further Reference:



Tech Support
Technotes
Previous Technote | Contents | Next Technote


Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help